package hotel.base.oversea.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;

/**
 * 美团酒店产品相关枚举
 * @Author qiuyy
 */
public class MtGoodsEnums {

    /**
     *  酒店营业状态：0 营业中1 已关门2 筹建中3 暂停营业
     */
    @Getter
    @AllArgsConstructor
    public enum needTelEnum {
        //是否需要用户真实手机号 0 不需要 1 需要
        NO(0, "需要"),
        YES(1, "不需要");
        private final int code;
        private final String msg;
    }

    @Getter
    @AllArgsConstructor
    public enum stateEnum {
        //房态：0 满房 1  可预订 2 不可预订 3  不展示
        FULL(0, "满房"),
        CAN(1, "可预订"),
        NOT(2, "不可预订书"),
        HIDE(3, "不展示");
        private final int code;
        private final String msg;
    }

    @Getter
    @AllArgsConstructor
    public enum roomDateTypeEnum {
        //产品类型
        DAY(1, "全日房）"),
        TIME(2, "钟点房"),
        ALL(3, "全日房和钟点房");
        private final int code;
        private final String msg;
    }
    @Getter
    @AllArgsConstructor
    public enum confirmEnum {
        //确认类型：0 不支持即时确认  1 支持即时确认
        YES(0, "不支持即时确认"),
        NO(1, "支持即时确认");
        private final int code;
        private final String msg;
    }
    @Getter
    @AllArgsConstructor
    public enum threeEnum {
        //是否第三方产品： 0 非第三方   1 第三方
        NO(0, "非第三方"),
        YES(1, "第三方");
        private final int code;
        private final String msg;
    }
    @Getter
    @AllArgsConstructor
    public enum breakfastEnum {
        //早餐类型：0 不含早餐 1 含有breakfastNum份免费早餐 2 收费早餐
        NO(0, "不含早餐"),
        FREE(1, "含有breakfastNum份免费早餐"),
        CASH(2, "收费早餐");
        private final int code;
        private final String msg;
    }

    @Getter
    @AllArgsConstructor
    public enum inventoryEnum {
        //库存情况：0 无库存1 有库存
        NO(0, "无库存"),
        YES(1, "有库存");
        private final int code;
        private final String msg;
    }

    /**
     * 价日类型
     */
    @Getter
    @AllArgsConstructor
    public enum priceDayEnum{
        DAILY(0, "平日"),
        WEEK(1, "周末"),
        SPEC(2, "特殊日");
        private final int code;
        private final String msg;
    }

    /**
     * 10 异步价格  11 主动查询价格 20 异步房态  21 主动查询房态 30 携程推送成功数据
     */
    @Getter
    @AllArgsConstructor
    public enum goodsChangeSource{
        NOTICE_PRICE(10, "异步价格"),
        PULL_PRICE(11, "主动查询价格"),
        PULL_ORDER_PRICE(12, "订单校验价格"),
        NOTICE_HHB_PRICE(13, "很好办异步价格"),
        NOTICE_STATUS(20, "异步房态"),
        PULL_STATUS(21, "主动查询房态"),
        NOTICE_HHB_STATUS(23, "很好办异步房态"),
        SWITCHS_PUSH(30, "携程推送成功数据");
        private final int code;
        private final String msg;
    }

    /**
     * 下单前试单 返回checkVo  code说明
     *
     *      * 校验结果码：
     *      * 0 校验成功--
     *      * 1 校验失败
     *      * 2 黑名单酒店
     *      * 3 房态不满足预订--
     *      * 4 三方产品不可售
     *      * 5 产品不存在
     *      * 6 产库存不足--
     *      * 7 未获取到价格
     *      * 8 价格发生变化---
     *      * 20 价格亏损超出
     *      * 非空：是
     *      *
     *      */
    @Getter
    @AllArgsConstructor
    public enum CheckStatus{
        SUCCESS(0, "校验成功"),
        FAILED(1, "校验失败"),
        BLACK(2, "黑名单酒店"),
        NO_ROOM(3, "房态不满足预订"),
        NO_SALE(4, "三方产品不可售"),
        LOSE(5, "产品不存在"),
        LESS_INVEN(6, "产库存不足"),
        NONE_PRICE(7, "未获取到价格"),
        CHANGE_PRICE(8, "价格发生变化"),
        OUT_LOSS_PRICE(20, "价格亏损超出上限"),
        OTHER_ERROR(99, "其他原因失败");
        private final int code;
        private final String msg;
    }

    /**
     * 延时单
     *
     *      * 0.0 定时器新订单下单
     *      *
     *      * 四大类，九小类
     *      *
     *      * 试单失败： 0 8 code正常，需再次判断价格
     *      *     库存不足：[JOBMT-CHECK] 订单将延迟处理 :2021-04-29 13:21:04  下单前校验未通过：{"code":6,"desc":"产品库存不足 - 产品id：62291352","priceModels":[],"remainRoomNum":0} 订单总价37128 订购房间数3 订单号=15039583130
     *      *     内部判断超亏损：[JOBMT-CHECK] 订单将延迟处理 :2021-04-29 12:47:55  单住订单，产品涨价超固定金额：总价10422 房间数1，亏损金额：11014,美团返回{"code":8,"desc":"下单卖价校验失败 - 产品id：608353023, 传入价格为：10422, 实际价格为：23300","priceModels":[{"date":"2021-05-01","dayType":0,"salePrice":23300,"subPrice":1864,"subRatio":800}],"remainRoomNum":999} 订单号=15039382839
     *      *     暂不可定：[JOBMT-CHECK] 订单将延迟处理 :2021-04-29 10:22:37  下单前校验未通过：{"code":3,"desc":"产品暂不可订 - 产品id：63194977，产品状态为：0","priceModels":[]} 订单总价18356 订购房间数1 订单号=15038611686
     *      *     命中黑名单(产品失效黑名单)：[JOBMT-CHECK] 订单将延迟处理 :2021-04-28 18:37:43  下单前校验未通过：{"code":2,"desc":"命中黑名单，暂不可售 - poiId：5223809，产品id：6570026，供应商id：12734","priceModels":[]} 订单总价24866 订购房间数1 订单号=15035473404
     *      *     其他：[JOBMT-CHECK] 订单将延迟处理 :2021-04-26 23:40:01  下单前校验未通过：{"code":5,"desc":"产品查询失败 - 产品id：674063758","priceModels":[]} 订单总价25946 订购房间数1 订单号=15020149938
     *      *
     *      * 异步通知失败：
     *      *     预定失败：[FAILED-NOTICE] 预下单已提交,但美团异步通知预定失败了！订单将延迟处理，请核实 :2021-04-29 12:15:49 {"method":"hotel.order.status.change.callback","data":"{\"mtOrderId\":4845882758375776398,\"distributorOrderId\":\"15039147320001\",\"orderStatus\":22,\"desc\":\"预定失败\"}","accesskey":"a6a02428da2c702188d7a8985fac24f6","signature":"XyJQM4nlyeSk2OL2lDgF4XDp1bQ=","partnerId":12734,"version":"1.0","nonce":1478396260,"timestamp":1619669748} 订单号：15039147320001
     *      *
     *      * 预下单失败：
     *      *      账户余额为零：[FAILED-BOOKING]下单前校验成功，但美团预下单失败，将延时处理 :2021-04-21 14:13:02：{"code":0,"message":"成功","partnerId":16366,"result":{"mtOrderId":null,"distributorOrderId":null,"code":5,"desc":"账户余额为零，扣款失败，请充值后重试"}} 订单号：14970451912
     *      *      其他： [FAILED-BOOKING]下单前校验成功，但美团预下单失败，将延时处理 :2021-04-29 00:27:32：{"code":0,"message":"成功","partnerId":12734,"result":{"mtOrderId":3422735875641244899,"distributorOrderId":"15037636697001","code":20,"desc":"预订信息校验失败"}} 订单号：15037636697
     *      *
     *      *早餐问题：
     *      *      早餐匹配不对： [JOBMT-CHECK] 订单将延迟处理 :2021-04-24 17:06:02 新订单校验，早餐信息变化产品早餐从免费变为无早，请核实 订单号=14998974435
     *      *
     *      * @return
     *
     *
     *      */
    @Getter
    @AllArgsConstructor
    public enum DelayStatus{
        CHECK_INV(11, "库存不足"),//试单失败//库存不足
        CHECK_MAX(12, "内部判断超亏损"),//试单失败//内部判断超亏损
        CHECK_STATUS(13, "暂不可订"),//试单失败//暂不可定
        CHECK_BLACK(14, "命中黑名单"),//试单失败//产品失效黑名单
        CHECK_LOW(15, "卖价校验失败"),//试单失败//卖价校验失败（远低于成本价）
        CHECK_OTHER(19, "其他失败"),//试单失败//其他失败
        BOOKING_ACCOUNT(21, "账户余额"),//预下单失败//余额不足
        BOOKING_OTHER(29, "其他失败"),//预下单失败//其他失败
        CALLBACK_FAILED(31, "预定失败"),//异步通知失败//预定失败
        BREAKFAST_OTHER(41, "早餐匹配异常");//早餐问题//早餐匹配异常
        private final int code;
        private final String msg;

        public static String getMsg(Integer code) {
            MtGoodsEnums.DelayStatus[] businessModeEnums = values();
            for (MtGoodsEnums.DelayStatus businessModeEnum : businessModeEnums) {
                if (BigDecimal.valueOf(businessModeEnum.code()).compareTo(new BigDecimal(code))==0) {
                    return businessModeEnum.msg();
                }
            }
            return null;
        }
        public static Integer contains(String content) {
            MtGoodsEnums.DelayStatus[] businessModeEnums = values();
            for (MtGoodsEnums.DelayStatus businessModeEnum : businessModeEnums) {
                if (content.contains(businessModeEnum.getMsg())) {
                    return businessModeEnum.getCode();
                }
            }
            return null;
        }
        public Integer code(){
            return this.code;
        }

        public String msg(){
            return this.msg;
        }
    }
    @Getter
    @AllArgsConstructor
    public enum DelayParentStatus{
        CHECK(10, "试单失败"),//试单失败
        BOOKING(20, "预下单失败"),//预下单失败
        CALLBACK(30, "异步通知失败"),//预订失败
        BREAKFAST(40, "早餐问题");//早餐问题
        private final int code;
        private final String msg;
    }

    /**
     * 0 push 往队列增加变更数据  1 pop 从队列中获取数据
     */
    @Getter
    @AllArgsConstructor
    public enum goodsChangeType{
        PUSH(0, "往队列增加变更数据"),
        POP(1, "从队列中获取数据");
        private final int code;
        private final String msg;
    }

}
